package com.huan.springcloud;

import java.util.concurrent.*;

public class JavaFuture {


    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newCachedThreadPool();
        Future<Integer> future = executorService.submit(new Task());
        System.out.println(future.get());
        executorService.shutdown();
    }


    private static class Task implements Callable<Integer> {
        @Override
        public Integer call() throws Exception {
            TimeUnit.SECONDS.sleep(2);
            return 1;
        }
    }
}
